package com.ruoyi.web.controller.obtain;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.obtain.domain.TValuationOnHelp;
import com.ruoyi.obtain.service.ITValuationOnHelpService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 帮扶评价Controller
 * 
 * @author ruoyi
 * @date 2022-11-11
 */
@RestController
@RequestMapping("/obtain/valuation")
public class TValuationOnHelpController extends BaseController
{
    @Autowired
    private ITValuationOnHelpService tValuationOnHelpService;

    /**
     * 查询帮扶评价列表
     */
    @PreAuthorize("@ss.hasPermi('obtain:valuation:list')")
    @GetMapping("/list")
    public TableDataInfo list(TValuationOnHelp tValuationOnHelp)
    {
        startPage();
        List<TValuationOnHelp> list = tValuationOnHelpService.selectTValuationOnHelpList(tValuationOnHelp);
        return getDataTable(list);
    }

    /**
     * 导出帮扶评价列表
     */
    @PreAuthorize("@ss.hasPermi('obtain:valuation:export')")
    @Log(title = "帮扶评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TValuationOnHelp tValuationOnHelp)
    {
        List<TValuationOnHelp> list = tValuationOnHelpService.selectTValuationOnHelpList(tValuationOnHelp);
        ExcelUtil<TValuationOnHelp> util = new ExcelUtil<TValuationOnHelp>(TValuationOnHelp.class);
        util.exportExcel(response, list, "帮扶评价数据");
    }

    /**
     * 获取帮扶评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('obtain:valuation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tValuationOnHelpService.selectTValuationOnHelpById(id));
    }

    /**
     * 新增帮扶评价
     */
    @PreAuthorize("@ss.hasPermi('obtain:valuation:add')")
    @Log(title = "帮扶评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TValuationOnHelp tValuationOnHelp)
    {
        return toAjax(tValuationOnHelpService.insertTValuationOnHelp(tValuationOnHelp));
    }

    /**
     * 修改帮扶评价
     */
    @PreAuthorize("@ss.hasPermi('obtain:valuation:edit')")
    @Log(title = "帮扶评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TValuationOnHelp tValuationOnHelp)
    {
        return toAjax(tValuationOnHelpService.updateTValuationOnHelp(tValuationOnHelp));
    }

    /**
     * 删除帮扶评价
     */
    @PreAuthorize("@ss.hasPermi('obtain:valuation:remove')")
    @Log(title = "帮扶评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tValuationOnHelpService.deleteTValuationOnHelpByIds(ids));
    }
}
